//
//  ConYueVc.m
//  Shengzhuli
//
//  Created by FXGuo on 2018/3/15.
//  Copyright © 2018年 kamangkeji. All rights reserved.
//

#import "ConYueVc.h"
#import "TGSementBarVC.h"
#import "ConYueViewController.h"
#import <Masonry.h>

#define SegmengH 45
@interface ConYueVc ()

@property (nonatomic,strong) TGSementBarVC *segmentBarVC;

@end

@implementation ConYueVc

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.title = @"约么";
    self.view.backgroundColor = [UIColor colorWithHexString:@"#efeff4"];
    [self setUpSegment];
    //选中segment的值
//    self.segmentBarVC.segmentBar.selectedIndex = self.type;
//    self.segmentBarVC.defaultSelectedIndex = self.type;
}

- (void)setUpSegment
{
    self.segmentBarVC.segmentBar.frame = CGRectMake(0, 0, ScreenW, SegmengH);
    [self.view addSubview:self.segmentBarVC.segmentBar];
    [self.segmentBarVC.segmentBar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(self.view);
        make.height.mas_equalTo(SegmengH);
    }];
//    self.segmentBarVC.view.frame = CGRectMake(0, SegmengH+5, ScreenW, ScreenH-SafeAreaTopHeight);
    [self.view addSubview:self.segmentBarVC.view];
    [self.segmentBarVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view).offset(SegmengH+5);
    }];
    
    [self addChildViewController:self.segmentBarVC];
    
    NSArray *items = @[@"全部",@"路演大会", @"平台活动", @"下午茶", @"结缘晚宴"];
    NSArray *type = @[@0,@4,@3,@1,@2];
    NSMutableArray* childVCs = [NSMutableArray array];
    for (NSInteger i=0; i<items.count; i++) {
        ConYueViewController *vc = [[ConYueViewController alloc]init];
        vc.type = [type[i] integerValue];
        [childVCs addObject:vc];
    }
    [self.segmentBarVC setupWithItems:items childVCs:childVCs];
    [self.segmentBarVC.segmentBar updateViewWithConfig:^(TGSegmentConfig *config) {
        config.segmentBarH = SegmengH;
        config.selectedColor([UIColor colorWithHexString:@"#3285ff"])
        .normalColor([UIColor colorWithHexString:@"#888888"])
        .selectedFont(Font(16))//选中字体大于其他正常标签的字体的情况下，根据情况稍微调大margin（默认8），以免选中的字体变大后挡住其他正常标签的内容
        .normalFont(Font(16))
        .indicateExtraW(0)
        .indicateH(2)
        .indicateColor([UIColor colorWithHexString:@"#3285ff"])//指示器颜色
        .showMore(NO)//是否显示更多面板
        .circleScroll(NO)//是否循环滚动，第0个再向前，那么到最后一个;最后一个向后，那么到第0个
        .moreCellBGColor([[UIColor grayColor] colorWithAlphaComponent:0.3])
        .moreBGColor([UIColor clearColor])
        .moreCellFont([UIFont systemFontOfSize:13])
        .moreCellTextColor(NavTinColor)
        .moreCellMinH(30)
        .showMoreBtnlineView(NO)
        .moreBtnlineViewColor([UIColor lightTextColor])
        .moreBtnTitleFont([UIFont systemFontOfSize:13])
        .moreBtnTitleColor([UIColor lightTextColor])
        .margin(25)
        .barBGColor([UIColor whiteColor])
        ;
    }];
}

- (TGSementBarVC *)segmentBarVC
{
    if (!_segmentBarVC) {
        _segmentBarVC = [[TGSementBarVC alloc] init];
    }
    return _segmentBarVC;
}

@end
